home *** CD-ROM | disk | FTP | other *** search
- Path: mail2news.demon.co.uk!genesis.demon.co.uk
- From: Lawrence Kirby <fred@genesis.demon.co.uk>
- Newsgroups: comp.lang.c
- Subject: Re: Recursion Question
- Date: Mon, 08 Apr 96 12:06:06 GMT
- Organization: none
- Message-ID: <828965166snz@genesis.demon.co.uk>
- References: <4k14o1$2k2@isis.fiu.edu> <3166CECC.354E@infi.net>
- Reply-To: fred@genesis.demon.co.uk
- X-NNTP-Posting-Host: genesis.demon.co.uk
- X-Newsreader: Demon Internet Simple News v1.27
- X-Mail2News-Path: genesis.demon.co.uk
-
- In article <3166CECC.354E@infi.net> srndtree@infi.net "Steve Rountree" writes:
-
- >A non-recursive method: (assuming a 16 bit integer)
- >
- > for(count=32768;count>0;count/=2){
- > printf("%d",(num & count ? 1 : 0));
- > }
-
- Be careful what type you make count. If it is a 16 bit int then it can't
- hold the number 32768 and the code has implementation-defined behaviour.
-
- --
- -----------------------------------------
- Lawrence Kirby | fred@genesis.demon.co.uk
- Wilts, England | 70734.126@compuserve.com
- -----------------------------------------
-